﻿<UserControl
    x:Class="WinRTXamlToolkit.Sample.Views.AutoCompleteTextBoxTestPage"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:WinRTXamlToolkit.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition
                Height="*" />
            <RowDefinition
                Height="5.55*" />
        </Grid.RowDefinitions>
        <FlipView
            UseTouchAnimationsForAllNavigation="True"
            Grid.Row="0"
            SelectionChanged="FlipView_SelectionChanged">
            <FlipView.Items>
                <FlipViewItem>
                    <TextBlock
                        Style="{StaticResource PageHeaderTextStyle}"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Top"
                        Margin="0 25 0 25"
                        Grid.Row="0"
                        Text="Settings" />
                </FlipViewItem>

                <FlipViewItem>
                    <TextBlock
                        Style="{StaticResource PageHeaderTextStyle}"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Top"
                        Margin="0 25 0 25"
                        Grid.Row="0"
                        Text="Control" />
                </FlipViewItem>
            </FlipView.Items>

        </FlipView>

        <Grid
            x:Name="settingsGrid"
            Visibility="Visible"
            Grid.Row="1">
            <StackPanel
                Margin="0 10 0 0">
                <TextBlock
                    Style="{StaticResource SubheaderTextStyle}"
                    HorizontalAlignment="Center"
                    Text="Pick maximum visible suggestion count (without scrolling):" />
                <Slider
                    Width="100"
                    Minimum="1"
                    Maximum="10"
                    Height="35"
                    Value="{Binding MaximalVisibleSuggestionCount, Mode=TwoWay}" />
                <TextBlock
                    Style="{StaticResource SubheaderTextStyle}"
                    HorizontalAlignment="Center"
                    Text="Pick suggestion algorithm:" />
                <ListBox
                    Foreground="Gray"
                    Width="250"
                    Height="150"
                    Margin="0 10 0 0"
                    SelectionChanged="AlgorithmListBox_SelectionChanged"
                    SelectedIndex="0">
                    <ContentControl
                        Height="30">
                        Levenshtein distance.
                    </ContentControl>
                    <ContentControl
                        Height="30">
                        Longest common substring.
                    </ContentControl>
                    <ContentControl
                        Height="30">
                        Prefix suggestion.
                    </ContentControl>
                </ListBox>
                <TextBlock
                    Style="{StaticResource SubheaderTextStyle}"
                    HorizontalAlignment="Center"
                    Text="Manage word dictionary (it will be used to give TextBox suggestions):" />
                <ListBox
                    x:Name="wordDictionaryListBox"
                    Height="150"
                    Width="500"
                    HorizontalAlignment="Center"
                    Margin="0 10 0 0"
                    ItemsSource="{Binding Dictionary}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock
                                Text="{Binding}"
                                Style="{StaticResource SubtitleTextBlockStyle}" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

                <StackPanel
                    Orientation="Horizontal"
                    Margin="5"
                    HorizontalAlignment="Center">
                    <TextBlock
                        Style="{StaticResource SubtitleTextBlockStyle}"
                        Margin="10 0 0 0"
                        VerticalAlignment="Center"
                        Text="Word to add:" />
                    <TextBox
                        x:Name="addWordTextBox"
                        Margin="10 0 0 0"
                        MinWidth="150"
                        MaxHeight="150"
                        VerticalAlignment="Center" />
                </StackPanel>

                <StackPanel
                    Orientation="Horizontal"
                    HorizontalAlignment="Center">
                    <Button
                        Click="AddWordToDictionaryButton_Click">Add word</Button>
                    <Button
                        Margin="10 0 0 0"
                        Click="RemoveWordFromDictionaryButton_Click">Remove word</Button>
                    <Button
                        Margin="10 0 0 0"
                        Command="{Binding ClearDictionaryCommand}">Clear word dictionary</Button>
                </StackPanel>
            </StackPanel>
        </Grid>

        <Grid
            x:Name="controlGrid"
            Visibility="Collapsed"
            Grid.Row="1"
            Margin="0,0,120,0">
            <Grid.RowDefinitions>
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="25" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="*" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="25" />
                <RowDefinition
                    Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <TextBlock
                Grid.ColumnSpan="2"
                Style="{StaticResource SubheaderTextBlockStyle}"
                Text="When there is enough space suggestions are displayed on bottom of TextBox. Type in TextBox to test:" />
            <TextBlock
                Grid.Row="2"
                Style="{StaticResource SubheaderTextBlockStyle}">
                <Run
                    Text="AutoCompleteTextBox Binding test: " />
                <Run
                    Text="{Binding FirstTextBoxText}" />
            </TextBlock>
            <controls:AutoCompleteTextBox
                Grid.Row="2"
                Grid.Column="1"
                MaximumVisibleSuggestions="{Binding MaximalVisibleSuggestionCount}"
                WordDictionary="{Binding Dictionary}"
                Text="{Binding FirstTextBoxText, Mode=TwoWay}"
                AutoCompleteService="{Binding AutoCompleteAlgorithm}" />

            <TextBlock
                Grid.Row="4"
                Grid.ColumnSpan="2"
                Style="{StaticResource SubheaderTextBlockStyle}"
                Text="When there is not enough space suggestions are displayed on top of TextBox. Type in TextBox to test:" />
            <TextBlock
                Grid.Row="6"
                Style="{StaticResource SubheaderTextBlockStyle}">
                <Run
                    Text="AutoCompleteTextBox Binding test: " />
                <Run
                    Text="{Binding SecondTextBoxText}" />
            </TextBlock>
            <controls:AutoCompleteTextBox
                Grid.Row="6"
                Grid.Column="1"
                Margin="0,0,0,25"
                ScrollBarBackground="White"
                ScrollBarBorderBrush="Black"
                Background="Wheat"
                Foreground="Black"
                BorderBrush="Black"
                ItemPointerOverBackgroundThemeBrush="AntiqueWhite"
                ItemPointerOverForegroundThemeBrush="Gray"
                MaximumVisibleSuggestions="{Binding MaximalVisibleSuggestionCount}"
                WordDictionary="{Binding Dictionary}"
                Text="{Binding SecondTextBoxText, Mode=TwoWay}"
                AutoCompleteService="{Binding AutoCompleteAlgorithm}" />
        </Grid>
    </Grid>
</UserControl>
